#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    cout<<"MON TUE WED THU FRI SAT SUN"<<endl;
    int month[13]={0,3,6,6,2,4,7,2,5,1,3,6,1};
    int date[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int m;
    scanf("%d",&m);
    for(int i=0;i<month[m]-1;i++)printf("    ");
    int day=1;
    while(day<=date[m]){
        printf("%3d",day);
        if((day+month[m]-1)%7==0)printf("\n");
        else printf(" ");
        day++;
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}